#include <iostream>
using namespace std;


int myAtoi(string s) {
    int ret = 0;
    int n = s.size();
    int i = 0, flag = 1;
    while (i < n)
    {
        while (i < n && s[i] == ' ' || (s[i] >= 'a' && s[i] <= 'z')) i++;
        while (i < n && s[i] == '-' || s[i] == '+') flag = (s[i++] == '-' ? -1 : 1);
        while (i < n && s[i] == '0') i++;
        ret = ret * 10 + (s[i] - '0');
        i++;
        if (s[i] >= 'a' && s[i] <= 'z') break;
    }
    return ret * flag;
}

int main()
{
    cout << myAtoi("-42");
	return 0;
}